﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Threading;
using System.Threading.Tasks;

using WSServer;

using Model;
using WeixinModel;

namespace XiJiaXi
{
    public class PushService
    {
        public static Task PushOnScreenStatToWedding(string wid,WeixinUser share)
        {
            return Task.Factory.StartNew(() =>
                {
                    Wedding wedding = WeddingContainer.sharedInstance.WeddingWithIdentifier(wid);
                    if (wedding != null)
                    {
                        string _wid = wedding.identifier;
                        WeddingOnScreenModel model = new WeddingOnScreenModel();
                        model.readCount = wedding.UserCount;
                        model.shareCount = wedding.ShareCount;
                        model.wid = wid;
                        model.onShare = share;
                        WSResponse response = new WSResponse()
                        {
                            identifier = wid,
                            type = WSResponseType.kWSResponseTypeMessage,
                            userinfo = model
                        };
                        WSUtils.sharedInstance.SendMessageToWSSocketWithIdentifier(_wid, response).Wait();
                    }
                });
        }
    }
}